package com.bflow.api.bo;

import com.bflow.commons.util.StrUtil;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @Name 默认路由组
 * @Author haowen
 * @Date 2018-12-29
 */
public class BflowDefineDefActRouteGroupBo implements Serializable {

    private BflowDefineActRouteBo routeNo;
    private BflowDefineActRouteBo routeYes;

    public BflowDefineDefActRouteGroupBo(BflowDefineActRouteBo routeNo, BflowDefineActRouteBo routeYes) {
        this.routeNo = routeNo;
        this.routeYes = routeYes;
    }

    public boolean hasNextAct() {
        if(routeYes != null){
            return StrUtil.isNotBlank(routeYes.getNextActId());
        }
        return false;
    }

    public BflowDefineActRouteBo getRouteNo() {
        return this.routeNo;
    }
    public void setRouteNo(BflowDefineActRouteBo routeNo) {
        this.routeNo = routeNo;
    }
    public BflowDefineActRouteBo getRouteYes() {
        return this.routeYes;
    }
    public void setRouteYes(BflowDefineActRouteBo routeYes) {
        this.routeYes = routeYes;
    }

    public List<BflowDefineActRouteBo> toList(){
        if(routeNo == null)
            return null;
        List<BflowDefineActRouteBo> list = new ArrayList<>(2);
        list.add(routeYes);
        list.add(routeNo);
        return list;
    }

    public BflowDefineActRouteBo getRouteById(String routeId){
        if(routeNo == null)
            return null;
        if(routeNo.getId().equals(routeId)){
            return routeNo;
        }
        if(routeYes.getId().equals(routeId)){
            return routeYes;
        }
        return null;
    }

}

